﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.Integration;

namespace HookupAppForm.Draw
{
    public partial class FrmWpfContainer : Form
    { 
        System.Windows.Controls.UserControl uc = null;

        public FrmWpfContainer(System.Windows.Controls.UserControl uc, string title, FormWindowState winstate, int sizeWidth = 0, int sizeHeight = 0)
        {
            InitializeComponent();
            this.uc = uc;
            WindowState = winstate;
            Text = title;
            Width = sizeWidth ;
            Height = sizeHeight;
            StartPosition = FormStartPosition.CenterParent;
            Load += FrmCustomDrawList_Load;
        }

        internal static void ShowDialog(System.Windows.Controls.UserControl uc, string title = "", FormWindowState winstate = FormWindowState.Normal, int sizeWidth = 0, int sizeHeight = 0)
        {
            var fm = new FrmWpfContainer(uc, title, winstate, sizeWidth, sizeHeight);
            fm.ShowDialog();
        }
        internal static void Show(System.Windows.Controls.UserControl uc, string title = "", FormWindowState winstate = FormWindowState.Normal, int sizeWidth = 0, int sizeHeight = 0)
        {
            var fm = new FrmWpfContainer(uc, title, winstate, sizeWidth, sizeHeight);
            fm.Show();
        }

        private void FrmCustomDrawList_Load(object sender, EventArgs e)
        {
            ElementHost eh = new ElementHost() { Dock = DockStyle.Fill };
            eh.Child = uc;
            panel1.Controls.Add(eh); 
        }
    }
}
